home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 298_01 / hello.c < prev    next >
C/C++ Source or Header  |  1987-03-28  |  1KB  |  51 lines

  1. /* hello.c - a simple curses program */
  2.  
  3. #include <curses.h>
  4.  
  5. main()
  6. {
  7.  WINDOW *win;
  8.  
  9.     /* initialize screen, and check for failure */
  10.     if( ERR == initscr() ) {
  11.         printf("initscr failed!\n");
  12.         exit(1);
  13.     }
  14.     /* set up 'win' to be the standard screen.
  15.      *  (Despite the macros for handling stdscr, it is 
  16.      *  easier in the long term not to use them.)
  17.      */
  18.     win = stdscr;
  19.  
  20.     /* set up tty modes */
  21.     raw();            /* ignore ^C, etc. */
  22.     noecho();        /* do not echo input */
  23.     keypad(win, TRUE);    /* should generally use this on the PC */
  24.     leaveok(win, TRUE);    /* turn off cursor for this window */
  25.     
  26.     /* position cursor and write message to window */
  27.     wmove(win, LINES/2, 22);
  28.     waddstr(win, "Hello world!");
  29.     
  30.     /* turn on inverse video mode */
  31.     wattrset(win, A_REVERSE);
  32.  
  33.     /* can write and move at the same time */
  34.     mvwaddstr(win, LINES/2+2, 18, "Hit any key to continue");
  35.  
  36.     /* turn off inverse video mode */
  37.     wattrset(win, 0);
  38.     
  39.     /* display the window */
  40.     wrefresh(win);
  41.     
  42.     /* wait for the user to press a key, discarding the input */
  43.     (void)wgetch(win);
  44.     
  45.     /* standard termination */
  46.     endwin();
  47.     
  48.     exit(0);
  49. }
  50.  
  51.